#ifndef _W25Q256_H_
#define _W25Q256_H_
//w25q256 指令表

#define W25Q256_WriteEnable		      0x06
#define W25Q256_ChipErase			  0xC7
#define W25Q256_SectorErase		    0x20 
#define W25Q256_SectorErase_4bitAddr 0x21
#define W25Q256_ReadStatusReg1		  0x05 
#define W25Q256_ReadStatusReg2		  0x35 
#define W25Q256_ReadStatusReg3		  0x15 

#define W25Q256_ReadDataReg           0x03
#define W25Q256_ReadDataReg_4bitAddr 0x13
#define W25Q256_PageProgram		    0x02 
#define W25Q256_PageProgram_4bitAddr 0x12
#define W25Q256_Enable4ByteAddr       0xB7

#define W25Q256_ManufactureID 0xEF
#define W25Q256_DeviceID 0x18

void spi0_CS0_init();

void spiInit(void);
unsigned char SPI_Transfers(unsigned char *tx,unsigned char *rx,unsigned int len);
void w25q256Init();
unsigned int W25Q256ReadID();
unsigned char W25Q256Read_SR(unsigned char regNo);
void W25Q256Read(unsigned char* pBuffer,unsigned int ReadAddr,unsigned int NumByteToRead);
void W25Q256Write(unsigned char* pBuffer,unsigned int WriteAddr,unsigned int NumByteToWrite);
void W25Q256SectorErase(unsigned int Dst_Addr);
void W25Q256WriteEnable(void);
void W25Q256WaitBusy(void);
void W25Q256Write_NoCheck(unsigned char* pBuffer,unsigned int WriteAddr,unsigned int NumByteToWrite);
void W25Q256Write_Page(unsigned char* pBuffer,unsigned int WriteAddr,unsigned int NumByteToWrite);

void spi0CS_high();
void spi0CS_low();


#endif